/*
 * Giffel, Android application
 *
 * Copyright (C) 2011  Mid Sweden University
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package se.appening;

import static se.appening.util.BitmapImageUtil.loadFrom;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

public class MapActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);

        ImageView mapView = (ImageView) findViewById(R.id.mapfigure);

        double userLat = 0.0;
        double userLong = 0.0;
        double itemLat = 0.0;
        double itemLong = 0.0;

        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            userLat = extras.getDouble("userLat");
            userLong = extras.getDouble("userLong");
            itemLat = extras.getDouble("itemLat");
            itemLong = extras.getDouble("itemLong");
        }

        String url = "http://maps.google.com/maps/api/staticmap?center="
                + userLat
                + ","
                + userLong
                + "&zoom=13&size=400x400&maptype=roadmap&sensor=false&markers=color:green|"
                + userLat + "," + userLong + "&markers=color:red|" + itemLat
                + "," + itemLong;

        mapView.setImageBitmap(loadFrom(url, this, R.drawable.empty));
    }

}
